#include "global.h"
#include "event_data.h"
#include "pokemon.h"
#include "random.h"
#include "roamer.h"
#include "constants/maps.h"
#include "constants/species.h"
#include "battle_debug.h"

enum
{
    MAP_GRP = 0, // map group
    MAP_NUM = 1, // map number
};

EWRAM_DATA static u8 sLocationHistory[3][2] = {0};
//EWRAM_DATA static u8 sRoamerLocation[2] = {0};
//EWRAM_DATA struct Roamer gSaveBlock1Ptr->gRoamers[ROAMER_NUM] = {0};

const struct RoamerStats gRoamerStats[ROAMER_NUM + 1] = {
	{
		.species = SPECIES_ARTICUNO,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_ZAPDOS,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_MOLTRES,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_RAIKOU,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_ENTEI,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_SUICUNE,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_REGIROCK,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_REGICE,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_REGISTEEL,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_LATIAS,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_LATIOS,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_UXIE,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_MESPRIT,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_AZELF,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_HEATRAN,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_REGIGIGAS,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_CRESSELIA,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_COBALION,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_TERRAKION,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_VIRIZION,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_TORNADUS,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_THUNDURUS,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_LANDORUS,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_TYPE_NULL,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_TAPU_KOKO,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_TAPU_LELE,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_TAPU_BULU,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_TAPU_FINI,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_REGIELEKI,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_REGIDRAGO,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_GLASTRIER,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_SPECTRIER,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_MEWTWO,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_LUGIA,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_HO_OH,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_DIALGA,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_PALKIA,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_GIRATINA,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_RESHIRAM,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_ZEKROM,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_KYUREM,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_XERNEAS,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_YVELTAL,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_ZYGARDE,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_COSMOG,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_COSMOG, //允许抓两次小星云
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_NECROZMA,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_ZACIAN,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_ZAMAZENTA,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_ETERNATUS,
		.canappearinwater = TRUE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_CALYREX,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_MAGEARNA,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_MARSHADOW,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
	{
		.species = SPECIES_MELTAN,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},{
		.species = SPECIES_ZARUDE,
		.canappearinwater = FALSE,
		.canappearinland = TRUE,
	},
    {
        .species = SPECIES_NONE, //结束
        .canappearinwater = FALSE,
        .canappearinland = FALSE,
    }
};

static const u8 sRoamerLocations[][6] =
{
    { MAP_NUM(ROUTE110), MAP_NUM(ROUTE111), MAP_NUM(ROUTE117), MAP_NUM(ROUTE118), MAP_NUM(ROUTE134), 0xFF },
    { MAP_NUM(ROUTE111), MAP_NUM(ROUTE110), MAP_NUM(ROUTE117), MAP_NUM(ROUTE118), 0xFF, 0xFF },
    { MAP_NUM(ROUTE117), MAP_NUM(ROUTE111), MAP_NUM(ROUTE110), MAP_NUM(ROUTE118), 0xFF, 0xFF },
    { MAP_NUM(ROUTE118), MAP_NUM(ROUTE117), MAP_NUM(ROUTE110), MAP_NUM(ROUTE111), MAP_NUM(ROUTE119), MAP_NUM(ROUTE123) },
    { MAP_NUM(ROUTE119), MAP_NUM(ROUTE118), MAP_NUM(ROUTE120), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE120), MAP_NUM(ROUTE119), MAP_NUM(ROUTE121), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE121), MAP_NUM(ROUTE120), MAP_NUM(ROUTE122), MAP_NUM(ROUTE123), 0xFF, 0xFF },
    { MAP_NUM(ROUTE122), MAP_NUM(ROUTE121), MAP_NUM(ROUTE123), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE123), MAP_NUM(ROUTE122), MAP_NUM(ROUTE118), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE124), MAP_NUM(ROUTE121), MAP_NUM(ROUTE125), MAP_NUM(ROUTE126), 0xFF, 0xFF },
    { MAP_NUM(ROUTE125), MAP_NUM(ROUTE124), MAP_NUM(ROUTE127), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE126), MAP_NUM(ROUTE124), MAP_NUM(ROUTE127), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE127), MAP_NUM(ROUTE125), MAP_NUM(ROUTE126), MAP_NUM(ROUTE128), 0xFF, 0xFF },
    { MAP_NUM(ROUTE128), MAP_NUM(ROUTE127), MAP_NUM(ROUTE129), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE129), MAP_NUM(ROUTE128), MAP_NUM(ROUTE130), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE130), MAP_NUM(ROUTE129), MAP_NUM(ROUTE131), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE131), MAP_NUM(ROUTE130), MAP_NUM(ROUTE132), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE132), MAP_NUM(ROUTE131), MAP_NUM(ROUTE133), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE133), MAP_NUM(ROUTE132), MAP_NUM(ROUTE134), 0xFF, 0xFF, 0xFF },
    { MAP_NUM(ROUTE134), MAP_NUM(ROUTE133), MAP_NUM(ROUTE110), 0xFF, 0xFF, 0xFF },
    { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
};

/*
void ClearRoamerData(void)
{
    memset(&gSaveBlock1Ptr->roamer, 0, sizeof(struct Roamer));
    (&gSaveBlock1Ptr->roamer)->species = SPECIES_LATIAS;
}
*/

void ClearRoamerLocationData(void)
{
    u8 i;

    for (i = 0; i < 3; i++)
    {
        sLocationHistory[i][MAP_GRP] = 0;
        sLocationHistory[i][MAP_NUM] = 0;
    }

    //sRoamerLocation[MAP_GRP] = 0;
    //sRoamerLocation[MAP_NUM] = 0;
}

/*
static void CreateInitialRoamerMon(bool16 createLatios)
{
    if (!createLatios)
        (&gSaveBlock1Ptr->roamer)->species = SPECIES_LATIAS;
    else
        (&gSaveBlock1Ptr->roamer)->species = SPECIES_LATIOS;

    CreateMon(&gEnemyParty[0], (&gSaveBlock1Ptr->roamer)->species, 40, 0x20, 0, 0, OT_ID_PLAYER_ID, 0);
    (&gSaveBlock1Ptr->roamer)->level = 40;
    (&gSaveBlock1Ptr->roamer)->status = 0;
    (&gSaveBlock1Ptr->roamer)->active = TRUE;
    (&gSaveBlock1Ptr->roamer)->ivs = GetMonData(&gEnemyParty[0], MON_DATA_IVS);
    (&gSaveBlock1Ptr->roamer)->personality = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY);
    (&gSaveBlock1Ptr->roamer)->hp = GetMonData(&gEnemyParty[0], MON_DATA_MAX_HP);
    (&gSaveBlock1Ptr->roamer)->cool = GetMonData(&gEnemyParty[0], MON_DATA_COOL);
    (&gSaveBlock1Ptr->roamer)->beauty = GetMonData(&gEnemyParty[0], MON_DATA_BEAUTY);
    (&gSaveBlock1Ptr->roamer)->cute = GetMonData(&gEnemyParty[0], MON_DATA_CUTE);
    (&gSaveBlock1Ptr->roamer)->smart = GetMonData(&gEnemyParty[0], MON_DATA_SMART);
    (&gSaveBlock1Ptr->roamer)->tough = GetMonData(&gEnemyParty[0], MON_DATA_TOUGH);
    sRoamerLocation[MAP_GRP] = 0;
    sRoamerLocation[MAP_NUM] = sRoamerLocations[Random() % (ARRAY_COUNT(sRoamerLocations) - 1)][0];
}
*/

static bool8 isMapNumOnLand(u8 mapnum)
{
	if ((mapnum >= 16 && mapnum <= 19) || (mapnum >= 25 && mapnum <= 36) || (38 == mapnum))
		return TRUE;
	else
		return FALSE;
}

static u8 GetValidMapNum(u8 type, u16 i)
{
	u16 j;
	u8 mapnum, locSet;
	
	if (0 == type)
	{
		for (j = 0; j < 100; j++) //防止卡死
		{
			mapnum = sRoamerLocations[Random() % (ARRAY_COUNT(sRoamerLocations) - 1)][0];
			
			if (gSaveBlock1Ptr->gRoamers[i].location[1] == mapnum)
				continue;
			if (!gRoamerStats[i].canappearinland)
				if (isMapNumOnLand(mapnum))
					continue;
			if (!gRoamerStats[i].canappearinwater)
				if (!isMapNumOnLand(mapnum))
					continue;
				
			break;
		}
		
		if (100 == j)
			return GetValidMapNum(1, i);
	}
	else
	{
		for (locSet = 0; locSet < (ARRAY_COUNT(sRoamerLocations) - 1); locSet++)
		{
			if (gSaveBlock1Ptr->gRoamers[i].location[1] == sRoamerLocations[locSet][0])
			{
				for (j = 0; j < 100; j++) //防止卡死
				{
					mapnum = sRoamerLocations[locSet][(Random() % 5) + 1];
					if (((0 == sLocationHistory[2][0]) && (mapnum == sLocationHistory[2][1])) || (0xFF == mapnum))
						continue;
					if (!gRoamerStats[i].canappearinland)
						if (isMapNumOnLand(mapnum))
							continue;
					if (!gRoamerStats[i].canappearinwater)
						if (!isMapNumOnLand(mapnum))
							continue;
					break;
				}
				
				if (100 == j)
					return GetValidMapNum(0, i);
			}
		}
	}
	return mapnum;
}

static u8 GetRoamerLevel(u16 species)
{
	switch (species)
	{
		case SPECIES_COSMOG:
		case SPECIES_MELTAN:
			return 5;
		default:
			return 50;
	}
}

void InitRoamer(void)
{
	u16 i;
	
    ClearRoamerLocationData();
    for (i = 0; i < ROAMER_NUM; i++)
	{
        CreateMon(&gEnemyParty[0], gRoamerStats[i].species, GetRoamerLevel(gRoamerStats[i].species), 32, 0, 0, 0, 0, 0);
		gSaveBlock1Ptr->gRoamers[i].ivs = GetMonData(&gEnemyParty[0], MON_DATA_IVS);
		gSaveBlock1Ptr->gRoamers[i].personality = GetMonData(&gEnemyParty[0], MON_DATA_PERSONALITY);
		gSaveBlock1Ptr->gRoamers[i].hp = GetMonData(&gEnemyParty[0], MON_DATA_MAX_HP);
		gSaveBlock1Ptr->gRoamers[i].status = 0;
		gSaveBlock1Ptr->gRoamers[i].active = TRUE;
		gSaveBlock1Ptr->gRoamers[i].location[0] = 0;
		gSaveBlock1Ptr->gRoamers[i].location[1] = GetValidMapNum(0, i);
	}
}

void UpdateLocationHistoryForRoamer(void)
{
    sLocationHistory[2][MAP_GRP] = sLocationHistory[1][MAP_GRP];
    sLocationHistory[2][MAP_NUM] = sLocationHistory[1][MAP_NUM];

    sLocationHistory[1][MAP_GRP] = sLocationHistory[0][MAP_GRP];
    sLocationHistory[1][MAP_NUM] = sLocationHistory[0][MAP_NUM];

    sLocationHistory[0][MAP_GRP] = gSaveBlock1Ptr->location.mapGroup;
    sLocationHistory[0][MAP_NUM] = gSaveBlock1Ptr->location.mapNum;
}

void RoamerMoveToOtherLocationSet(void)
{
	/*
    u8 mapNum = 0;
    struct Roamer *roamer = &gSaveBlock1Ptr->roamer;

    if (!roamer->active)
        return;

    sRoamerLocation[MAP_GRP] = 0;

    while (1)
    {
        mapNum = sRoamerLocations[Random() % (ARRAY_COUNT(sRoamerLocations) - 1)][0];
        if (sRoamerLocation[MAP_NUM] != mapNum)
        {
            sRoamerLocation[MAP_NUM] = mapNum;
            return;
        }
    }
	*/
	
	u16 i;
	
	for (i = 0; i < ROAMER_NUM; i++)
		if (gSaveBlock1Ptr->gRoamers[i].active)
			gSaveBlock1Ptr->gRoamers[i].location[1] = GetValidMapNum(0, i);
}

void RoamerMove(void)
{
	/*
    u8 locSet = 0;

    if ((Random() % 16) == 0)
    {
        RoamerMoveToOtherLocationSet();
    }
    else
    {
        struct Roamer *roamer = &gSaveBlock1Ptr->roamer;

        if (!roamer->active)
            return;

        while (locSet < (ARRAY_COUNT(sRoamerLocations) - 1))
        {
            if (sRoamerLocation[MAP_NUM] == sRoamerLocations[locSet][0])
            {
                u8 mapNum;
                while (1)
                {
                    mapNum = sRoamerLocations[locSet][(Random() % 5) + 1];
                    if (!(sLocationHistory[2][MAP_GRP] == 0 && sLocationHistory[2][MAP_NUM] == mapNum) && mapNum != 0xFF)
                        break;
                }
                sRoamerLocation[MAP_NUM] = mapNum;
                return;
            }
            locSet++;
        }
    }
	*/
	
	u16 i;
	u8 type;
	
	for (i = 0; i < ROAMER_NUM; i++)
	{
		if (gSaveBlock1Ptr->gRoamers[i].active)
		{	
			type = (0 != (Random() % 16));	
			gSaveBlock1Ptr->gRoamers[i].location[1] = GetValidMapNum(type, i);
		}
	}
}

bool8 IsRoamerAt(u16 i, u8 mapGroup, u8 mapNum)
{
    if (mapGroup == gSaveBlock1Ptr->gRoamers[i].location[0] && mapNum == gSaveBlock1Ptr->gRoamers[i].location[1])
        return TRUE;
    else
        return FALSE;
}

/*
void CreateRoamerMonInstance(void)
{
    struct Pokemon *mon;
    struct Roamer *roamer;

    mon = &gEnemyParty[0];
    ZeroEnemyPartyMons();
    roamer = &gSaveBlock1Ptr->roamer;
    CreateMonWithIVsPersonality(mon, roamer->species, roamer->level, roamer->ivs, roamer->personality);
    SetMonData(mon, MON_DATA_STATUS, &gSaveBlock1Ptr->roamer.status);
    SetMonData(mon, MON_DATA_HP, &gSaveBlock1Ptr->roamer.hp);
    SetMonData(mon, MON_DATA_COOL, &gSaveBlock1Ptr->roamer.cool);
    SetMonData(mon, MON_DATA_BEAUTY, &gSaveBlock1Ptr->roamer.beauty);
    SetMonData(mon, MON_DATA_CUTE, &gSaveBlock1Ptr->roamer.cute);
    SetMonData(mon, MON_DATA_SMART, &gSaveBlock1Ptr->roamer.smart);
    SetMonData(mon, MON_DATA_TOUGH, &gSaveBlock1Ptr->roamer.tough);
}
*/

#if USE_BATTLE_DEBUG == 1
void Debug_SeenAndCaughtAllPM(void)
{
    register u16 i;
    for (i = 0; i < DEX_FLAGS_NO; i++)
    {
        gSaveBlock1Ptr->dexSeen[i] = 0xFF;
        gSaveBlock1Ptr->dexCaught[i] = 0xFF;
    }
}
#endif

bool8 TryStartRoamerEncounter(void)
{
	/*
    if (IsRoamerAt(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum) == TRUE && (Random() % 4) == 0)
    {
        CreateRoamerMonInstance();
        return TRUE;
    }
    else
    {
        return FALSE;
    }
	*/
	
	u16 i, j = 0;
    u8 activecounts = 0;
    u8 table[ROAMER_NUM] = {0};
    if(FlagGet(FLAG_SYS_DEXNAV_SEARCH))
		return FALSE;
    for (i = 0; i < ROAMER_NUM; i++)
    {
        if (gSaveBlock1Ptr->gRoamers[i].active)
            activecounts++;
    }

	for (i = 0; i < ROAMER_NUM; i++)
	{
        if (gSaveBlock1Ptr->gRoamers[i].active && IsRoamerAt(i, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum) && (Random() % (4 * activecounts)) == 0)
            table[j++] = i;
	}

    if (j)
    {
        j = Random() % j;
        i = table[j]; //随机选取
        CreateMonWithIVsPersonality(&gEnemyParty[0], gRoamerStats[i].species, GetRoamerLevel(gRoamerStats[i].species),
                                    gSaveBlock1Ptr->gRoamers[i].ivs, gSaveBlock1Ptr->gRoamers[i].personality, 1);
        SetMonData(&gEnemyParty[0], MON_DATA_STATUS, &gSaveBlock1Ptr->gRoamers[i].status);
        SetMonData(&gEnemyParty[0], MON_DATA_HP, &gSaveBlock1Ptr->gRoamers[i].hp);

        return TRUE;
    }
	return FALSE;
}

void UpdateRoamerHPStatus(struct Pokemon *mon)
{
	/*
    (&gSaveBlock1Ptr->roamer)->hp = GetMonData(mon, MON_DATA_HP);
    (&gSaveBlock1Ptr->roamer)->status = GetMonData(mon, MON_DATA_STATUS);

    RoamerMoveToOtherLocationSet();
	*/
	
	u16 i;
	u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL);
	
	for (i = 0; i < ROAMER_NUM; i++)
	{
		if (species == gRoamerStats[i].species)
		{
			gSaveBlock1Ptr->gRoamers[i].status = GetMonData(mon, MON_DATA_STATUS, NULL);
			gSaveBlock1Ptr->gRoamers[i].hp = GetMonData(mon, MON_DATA_HP, NULL);
			break;
		}
	}

    RoamerMoveToOtherLocationSet();
}

void SetRoamerInactive(void)
{
	/*
    struct Roamer *roamer = &gSaveBlock1Ptr->roamer;
    roamer->active = FALSE;
	*/
	
	u16 i;
	u16 species = GetMonData(&gEnemyParty[0], MON_DATA_SPECIES, NULL);
	
	for (i = 0; i < ROAMER_NUM; i++)
		if (gRoamerStats[i].species == species)
			gSaveBlock1Ptr->gRoamers[i].active = FALSE;
}

void GetRoamerLocation(u8 *mapGroup, u8 *mapNum, u8 i)
{
	/*
    *mapGroup = sRoamerLocation[MAP_GRP];
    *mapNum = sRoamerLocation[MAP_NUM];
	*/
	
	*mapGroup = gSaveBlock1Ptr->gRoamers[i].location[0];
    *mapNum = gSaveBlock1Ptr->gRoamers[i].location[1];
}
